home *** CD-ROM | disk | FTP | other *** search
/ BUG 1 / BUGCD1996_0708.ISO / mac / Alati / GrafiËka pomagala / clip2gif 0.7.2.1 / Calling clip2gif from C / LoadClip2Gif.h < prev   
Text File  |  1995-12-19  |  7KB  |  253 lines

  1. /*
  2.  *    LoadClip2Gif.h
  3.  *
  4.  *    Copyright 1995, Yves Piguet. All right reserved.
  5.  *    
  6.  *    Definitions and prototypes to use clip2gif as a library.
  7.  */
  8.  
  9. #ifndef __LoadClip2Gif__
  10. #define __LoadClip2Gif__
  11.  
  12. #include <Types.h>
  13. #include <Files.h>
  14.  
  15. #ifndef colorPaletteSystem
  16. #define colorPaletteSystem ((CTabHandle)0)
  17. #define colorPaletteGrayScale ((CTabHandle)-1)
  18. #define colorPaletteCustom ((CTabHandle)-2)
  19. #endif
  20.  
  21. #ifndef transparencyNo
  22. #define transparencyNo ((RGBColor *)0)
  23. #define transparencyWhite ((RGBColor *)-1)
  24. #define transparencyFirstPixel ((RGBColor *)-2)
  25. #endif
  26.  
  27. #ifndef errNotGifFile
  28. #define errNotGifFile -20100
  29. #define errBadGifFile -20101
  30. #define errNoGifDecoder -20102
  31. #endif
  32.  
  33. #ifndef errUnknownFileType
  34. #define errUnknownFileType -20018
  35. #endif
  36.  
  37.  
  38. typedef struct
  39. {
  40.     PixMapHandle pixmap;    // only this field is public
  41.     
  42.     long private[3];
  43. } Offscreen;
  44.  
  45.  
  46. /*
  47.  *    err = LoadClip2Gif(void)
  48.  *
  49.  *    Description:
  50.  *
  51.  *    Loads clip2gif and resolves symbols. clip2gif should be on the same volume as
  52.  *    the calling program.
  53.  */
  54.  
  55. OSErr LoadClip2Gif(void);
  56.  
  57. /*
  58.  *    Defined functions:
  59.  *    ==================
  60.  *    
  61.  *    version = GetVersionNumber();
  62.  *    
  63.  *    Description:
  64.  *    
  65.  *    Returns the version number of clip2gif (e.g. 71 for 0.7.1).
  66.  *    Allows to check that it's the correct one.
  67.  *    
  68.  *    -----
  69.  *    
  70.  *    err = BeginOffscreen(&os, width, height, depth, clut);
  71.  *    
  72.  *    Description:
  73.  *    
  74.  *    Allocates a new offscreen pixmap, erases it and sets the GrafPort
  75.  *    
  76.  *    Parameters:
  77.  *    
  78.  *    Offscreen os        new offscreen data (initialized by BeginOffscreen)
  79.  *    short width            offscreen width
  80.  *    short height        offscreen height
  81.  *    short depth            offscreen depth (should be 1, 2, 4 or 8 if used with
  82.  *                            ConvertPixmapTo... later)
  83.  *    CTabHandle clut        color lookup table, or colorPaletteSystem or colorPaletteGrayScale
  84.  *                            (NOT colorPaletteCustom)
  85.  *    
  86.  *    -----
  87.  *    
  88.  *    err = DisposeOffscreen(&os);
  89.  *    
  90.  *    Description:
  91.  *    
  92.  *    Disposes an offscreen allocated by BeginOffscreen and restores the old GrafPort
  93.  *    
  94.  *    Parameters:
  95.  *    
  96.  *    Offscreen os        offscreen data
  97.  *    
  98.  *    -----
  99.  *    
  100.  *    err = ConvertPictToGIFHandle(thePic, gifHandle, interlaced, transparency, depth, colors);
  101.  *
  102.  *    Description:
  103.  *
  104.  *    Converts a pict to a GIF handle
  105.  *    
  106.  *    Parameters:
  107.  *
  108.  *    OSErr err            noErr if successful, error code otherwise
  109.  *    PicHandle thePic    input picture
  110.  *    Handle gifHandle    output GIF handle (a new handle is allocated)
  111.  *    short interlaced    0 if the GIF scanlines are not interlaced, 1 if they are
  112.  *    RGBColor *transparency
  113.  *                        one of the magic values defined above, or transparent color
  114.  *    short depth            number of bits per pixel (1, 2, 4 or 8)
  115.  *    CTabHandle clut:     color lookup table, or colorPaletteSystem,
  116.  *                                colorPaletteGrayScale or colorPaletteCustom
  117.  *
  118.  *    -----
  119.  *
  120.  *    err = ConvertPictToGIFFile(thePic, gifFile, interlaced, transparency, depth, colors);
  121.  *
  122.  *    Description:
  123.  *
  124.  *    Converts a pict to a GIF file
  125.  *    
  126.  *    Parameters:
  127.  *
  128.  *    OSErr err            noErr if successful, error code otherwise
  129.  *    PicHandle thePic    input picture
  130.  *    FSSpec *gifFile        output GIF file
  131.  *    short interlaced    0 if the GIF scanlines are not interlaced, 1 if they are
  132.  *    RGBColor *transparency
  133.  *                        one of the magic values defined above, or transparent color
  134.  *    short depth            number of bits per pixel (1, 2, 4 or 8)
  135.  *    CTabHandle clut:     color lookup table, or colorPaletteSystem,
  136.  *                                colorPaletteGrayScale or colorPaletteCustom
  137.  *
  138.  *    -----
  139.  *
  140.  *    err = ConvertFileToPict(theFile, &thePic);
  141.  *
  142.  *    Description:
  143.  *
  144.  *    Reads a PICT, GIF, TIFF or JPEG file and stores it into a PicHandle
  145.  *
  146.  *    Parameters:
  147.  *
  148.  *    OSErr err            noErr if successful, error code otherwise
  149.  *    FSSpec *theFile        input file
  150.  *    PicHandle thePic    output picture
  151.  *
  152.  *    -----
  153.  *
  154.  *    err = ConvertPictToTIFFHandle(thePic, tiffHandle, depth, bigEndian);
  155.  *
  156.  *    Purpose:
  157.  *
  158.  *    Converts a pict to a TIFF handle
  159.  *    
  160.  *    Parameters:
  161.  *
  162.  *    OSErr err            noErr if successful, error code otherwise
  163.  *    PicHandle thePic    input picture
  164.  *    Handle tiffHandle    output TIFF Handle
  165.  *    short depth            number of bits per pixel (16 or 32)
  166.  *    short bigEndian        0 for little endian (Transputers and others),
  167.  *                        1 for big endian (Motorola, SPARC, etc.)
  168.  *
  169.  *    -----
  170.  *
  171.  *    err = ConvertPictToTIFFFile(thePic, tiffFile, depth, bigEndian);
  172.  *
  173.  *    Purpose:
  174.  *
  175.  *    Converts a pict to a TIFF file
  176.  *    
  177.  *    Parameters:
  178.  *
  179.  *    OSErr err            noErr if successful, error code otherwise
  180.  *    PicHandle thePic    input picture
  181.  *    FSSpec tiffFile        output TIFF FSSpec
  182.  *    short depth            number of bits per pixel (16 or 32)
  183.  *    short bigEndian        0 for little endian (Transputers and others),
  184.  *                        1 for big endian (Motorola, SPARC, etc.)
  185.  *
  186.  *    -----
  187.  *    
  188.  *    err = ConvertPictToJPEGHandle(thePic, jpegHandle, depth, quality);
  189.  *
  190.  *    Purpose:
  191.  *
  192.  *    Converts a pict to a JPEG handle
  193.  *    
  194.  *    Parameters:
  195.  *
  196.  *    OSErr err            noErr if successful, error code otherwise
  197.  *    PicHandle thePic    input picture
  198.  *    Handle jpegHandle    output JPEG handle (a new handle is allocated)
  199.  *    short depth            number of bits per pixel (16 or 32)
  200.  *    short quality        JPEG compression quality (0 = bad, 4 = very good)
  201.  *    
  202.  *    -----
  203.  *    
  204.  *    err = ConvertPictToJPEGFile(thePic, jpegFile, depth, quality);
  205.  *
  206.  *    Purpose:
  207.  *
  208.  *    Converts a pict to a JPEG file
  209.  *    
  210.  *    Parameters:
  211.  *
  212.  *    OSErr err            noErr if successful, error code otherwise
  213.  *    PicHandle thePic    input picture
  214.  *    FSSpec jpegFile        output JPEG FSSpec
  215.  *    short depth            number of bits per pixel (16 or 32)
  216.  *    short quality        JPEG compression quality (0 = bad, 4 = very good)
  217.  *
  218.  *    -----
  219.  *
  220.  *    err = GetScreen(&crop, &thePic)
  221.  *
  222.  *    Description:
  223.  *
  224.  *    Converts a rectangular piece of the screen into a PicHandle
  225.  *
  226.  *    Parameters:
  227.  *
  228.  *    OSErr err            noErr if successful, error code otherwise
  229.  *    Rect crop            cropping rectangle in global coordinates (full screen if null)
  230.  *    PicHandle thePic    output picture
  231.  */
  232.  
  233.  
  234. /*
  235.  *    CFM stuff
  236.  */
  237.  
  238. extern short (*GetVersionNumber)(void);
  239. extern OSErr (*BeginOffscreen)(Offscreen *, short, short, short, CTabHandle);
  240. extern OSErr (*DisposeOffscreen)(Offscreen *);
  241. extern OSErr (*ConvertFileToPict)(PicHandle, Handle *);
  242. extern OSErr (*ConvertPictToGIFFile)(PicHandle, FSSpec *, short, RGBColor *, short, CTabHandle);
  243. extern OSErr (*ConvertPictToGIFHandle)(PicHandle, Handle *, short, RGBColor *, short, CTabHandle);
  244. extern OSErr (*ConvertPixmapToGIFHandle)(PixMapHandle, Handle *, short, RGBColor *);
  245. extern OSErr (*ConvertPixmapToGIFFile)(PixMapHandle, FSSpec *, short, RGBColor *);
  246. extern OSErr (*ConvertPictToJPEGHandle)(PicHandle, Handle *, short, short);
  247. extern OSErr (*ConvertPictToJPEGFile)(PicHandle, FSSpec *, short, short);
  248. extern OSErr (*ConvertPictToTIFFHandle)(PicHandle, Handle *, short, short);
  249. extern OSErr (*ConvertPictToTIFFFile)(PicHandle, FSSpec *, short, short);
  250. extern OSErr (*GetScreen)(Rect *, PicHandle *);
  251.  
  252. #endif
  253.